package com.hwadee.controller;

import com.hwadee.pojo.Alert;
import com.hwadee.service.AlertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/hd/alert")
@CrossOrigin
public class AlertController {

    @Autowired
    private AlertService alertService;

    @GetMapping("/list")
    public List<Alert> getAllAlerts() {
        return alertService.getAllAlerts();
    }

    @PostMapping("/add")
    public int addAlert(@RequestBody Alert alert) {
        return alertService.addAlert(alert);
    }

    @DeleteMapping("/delete/{id}")
    public int deleteAlert(@PathVariable Integer id) {
        return alertService.deleteAlert(id);
    }

    @PutMapping("/update")
    public int updateAlert(@RequestBody Alert alert) {
        return alertService.updateAlert(alert);
    }
}

